package org.example.mybatis.model;

import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-07-10
 * Time: 14:38
 */

@Mapper
public interface UserInfoMapper {
    /**
     * 结果映射
     * 方法一: 对字段进行重命名
     * @return
     */

    @Select("select * from userinfo")
    List<UserInfo> selectAll();

    @Select("select * from userinfo where id= #{id}")
    public UserInfo select_by_one_id(Integer id);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into userinfo (username, `password`, age, gender, phone) " +
            "values (#{username},#{password},#{age},#{gender},#{phone})")
    public  Integer insert(UserInfo userInfo);

    @Delete("delete from userinfo where id = #{id}")
    void delete(Integer id);
}
